import time

from django.test import TestCase

from Robots.HDU import HDURobot
from Robots.RobotFactory import RobotFactory


class HDUTestCase(TestCase):
    def setUp(self):
        self.robot = HDURobot(username='xiaoqiuuuu', password='zxx20030411..')

    def test_robot_login_submit(self):
        self.robot.login(username='xiaoqiuuuu', password='zxx20030411..')
        assert self.robot.is_logged_in
        sid = self.robot.submit("https://acm.hdu.edu.cn/submit.php?action=submit" , code=r'''
        #include <bits/stdc++.h>
            using namespace std;
            using LL = long long;
            void solve(){
                int n;
                cin >> n;
                
                vector<LL> f(n + 1 , 0);
                f[1] = 1 , f[2] = 2;
                
                for(int i = 3 ; i <= n ; i ++ ) {
                    f[i] = f[i - 1] + f[i - 2];
                }
            
                
                string ans = "";
                while(f[n]) {
                    ans += ('0' + f[n] % 10);
                    f[n] /= 10;
                }
                cout << ans << "\n";
            
                
                return ;
            }
            
            int main(){
                ios::sync_with_stdio(false);
                cin.tie(nullptr);
                
                int tt = 1;
                //cin >> tt ;
                while(tt --> 0){
                    solve();
                }
                
                return 0;
            }       
        ''' , origin_id="1001")

        time.sleep(2)
        print(self.robot.get_result(submission_id=sid))
        self.robot.release()

    def test_robot_get_problem(self):
        pass
        data = self.robot.get_problem(problem_id="1152")

        for x , y in data.items():
            print(x , ":",  y)
